<?php
$what = $_GET['insert']?$_GET['insert']:'dataimport';
$table = $_GET['table']?$_GET['table']:'content';
//if (!empty($_GET['insert'])){$what=$_GET['insert'];}else{$what='dataimport';}
$files = read_dir2("../content/".$what."/");

function read_dir2($dir, $array = array()){
	$dh = opendir($dir);
	$files = array();
	while (($file = readdir($dh)) !== false) {
		$file = autoiconv2($file);
		if($file !== '.' && $file !== '..' && !in_array($file, $array) && extend($file)=='xls') {
			$files[]=$file;
		}
	}
	return $files;
}
function autoiconv2($str){
	if($str){
		$charSet = mb_detect_encoding($str, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII'));
		return iconv($charSet,"utf-8", $str);
	}
}
function extend($file_name)
{
	$extend = pathinfo($file_name);
	$extend = strtolower($extend["extension"]);
	return $extend;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>import</title>
</head>
<script type="text/javascript">
function import2(){
	//alert(111);
	if(!confirm("是否导入?")){return false;}
}
</script>
<body>
<div>
	<ul>
	<?php foreach ($files as $key=>$item):
		if (substr($item, 0,10)>=date("Y-m-d",strtotime("-2 day"))):
	?>
		<li><?php echo $item;?>&nbsp;&nbsp;&nbsp;&nbsp;<a href="dataimport2.php?date=<?php echo urlencode($item);?>&what=<?php echo $what;?>&table=<?php echo $table;?>&" onclick="return import2()">导入</a></li>
	<?php endif; endforeach;?>
	</ul>
</div>
</body>
</html>